package com.example.springboot.controller.api;

import cn.hutool.core.date.DateUtil;
import com.example.springboot.common.Result;
import com.example.springboot.entity.Feedback;
import com.example.springboot.mapper.FeedbackMapper;
import com.example.springboot.service.IFeedbackService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 举报表 API控制器 - 不需要token验证的API
 * </p>
 *
 * @author
 */
@RestController
@RequestMapping("/api/feedback")
public class FeedbackApi {
    @Resource
    private IFeedbackService feedbackService;

    private final String now = DateUtil.now();

    // 新增或者更新
    @PostMapping
    public Result save(@RequestBody Feedback feedback) {
        if (feedback.getId() == null) {
            //feedback.setTime(DateUtil.now());
            //feedback.setUser(TokenUtils.getCurrentUser().getUsername());
        }
        feedbackService.saveOrUpdate(feedback);
        return Result.success();
    }
}
